<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 6.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/Horse.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/Horse.png">
  <link rel="mask-icon" href="/blog/images/logo.svg" color="#222">

<link rel="stylesheet" href="/blog/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha256-HtsXJanqjKTc8vVQjO4YMhiqFoXkfBsjBWcX91T1jr8=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css" integrity="sha256-Vzbj7sDDS/woiFS3uNKo8eIuni59rjyNGtXfstRzStA=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"yanlwsometing.gitee.io","root":"/blog/","images":"/blog/images","scheme":"Pisces","darkmode":false,"version":"8.16.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"show_result":true,"style":"flat"},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":false,"async":false,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"}}</script><script src="/blog/js/config.js"></script>

    <meta name="description" content="OCaml安装（win10）这里我只推荐安装虚拟机Ubuntu，都是血泪史，为了搞这个环境我废了两天:sob:。 如果你不想看我的吐槽小作文，可以直接跳到Ubuntu 注意：建议别搜索教程(我的除外:yum:)，先看官方文档：Get Up and Running With OCaml · OCaml Tutorials">
<meta property="og:type" content="article">
<meta property="og:title" content="OCaml初识">
<meta property="og:url" content="https://yanlwsometing.gitee.io/blog/2023/05/18/OCaml%E5%88%9D%E8%AF%86/index.html">
<meta property="og:site_name" content="yanlwsometing">
<meta property="og:description" content="OCaml安装（win10）这里我只推荐安装虚拟机Ubuntu，都是血泪史，为了搞这个环境我废了两天:sob:。 如果你不想看我的吐槽小作文，可以直接跳到Ubuntu 注意：建议别搜索教程(我的除外:yum:)，先看官方文档：Get Up and Running With OCaml · OCaml Tutorials">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://yanlwsometing.gitee.io/blog/images/OCaml%E5%88%9D%E8%AF%86/image-20230519154156905.png">
<meta property="og:image" content="https://yanlwsometing.gitee.io/blog/images/OCaml/image-20230522215152491.png">
<meta property="og:image" content="https://yanlwsometing.gitee.io/blog/images/OCaml%E5%88%9D%E8%AF%86/image-20230519155022482.png">
<meta property="og:image" content="https://yanlwsometing.gitee.io/blog/images/OCaml%E5%88%9D%E8%AF%86/image-20230519120146856.png">
<meta property="og:image" content="https://yanlwsometing.gitee.io/blog/images/OCaml%E5%88%9D%E8%AF%86/image-20230519120306108.png">
<meta property="og:image" content="https://yanlwsometing.gitee.io/blog/images/OCaml/image-20230519160059551.png">
<meta property="og:image" content="https://yanlwsometing.gitee.io/blog/images/OCaml%E5%88%9D%E8%AF%86/image-20230519120351677.png">
<meta property="og:image" content="https://yanlwsometing.gitee.io/blog/images/OCaml%E5%88%9D%E8%AF%86/image-20230519120427199.png">
<meta property="article:published_time" content="2023-05-18T09:51:49.000Z">
<meta property="article:modified_time" content="2023-12-15T08:56:34.741Z">
<meta property="article:author" content="yanlw">
<meta property="article:tag" content="wsl2">
<meta property="article:tag" content="函数式编程">
<meta property="article:tag" content="VMware">
<meta property="article:tag" content="ocaml安装">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://yanlwsometing.gitee.io/blog/images/OCaml%E5%88%9D%E8%AF%86/image-20230519154156905.png">


<link rel="canonical" href="https://yanlwsometing.gitee.io/blog/2023/05/18/OCaml%E5%88%9D%E8%AF%86/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://yanlwsometing.gitee.io/blog/2023/05/18/OCaml%E5%88%9D%E8%AF%86/","path":"2023/05/18/OCaml初识/","title":"OCaml初识"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>OCaml初识 | yanlwsometing</title>
  








  <noscript>
    <link rel="stylesheet" href="/blog/css/noscript.css">
  </noscript>
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/blog/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">yanlwsometing</p>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/blog/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-tags"><a href="/blog/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li><li class="menu-item menu-item-categories"><a href="/blog/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li><li class="menu-item menu-item-archives"><a href="/blog/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a></li><li class="menu-item menu-item-commonweal"><a href="/blog/404/" rel="section"><i class="fa fa-heartbeat fa-fw"></i>公益 404</a></li>
  </ul>
</nav>




</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#OCaml%E5%AE%89%E8%A3%85%EF%BC%88win10%EF%BC%89"><span class="nav-number">1.</span> <span class="nav-text">OCaml安装（win10）</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-Windows"><span class="nav-number">1.1.</span> <span class="nav-text">1 Windows</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#1-1-WSL2-VScode"><span class="nav-number">1.1.1.</span> <span class="nav-text">1.1  WSL2+VScode</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#1-2-Cygwin"><span class="nav-number">1.1.2.</span> <span class="nav-text">1.2 Cygwin</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-CentOS"><span class="nav-number">1.2.</span> <span class="nav-text">2 CentOS</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-Ubuntu"><span class="nav-number">1.3.</span> <span class="nav-text">3 Ubuntu</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#OCaml%E5%88%9D%E5%A7%8B"><span class="nav-number">2.</span> <span class="nav-text">OCaml初始</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-%E7%BC%96%E7%A8%8B%E8%8C%83%E5%BC%8F%E5%AF%B9%E6%AF%94"><span class="nav-number">2.1.</span> <span class="nav-text">1 编程范式对比</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#2-%E7%89%B9%E7%82%B9"><span class="nav-number">2.2.</span> <span class="nav-text">2 特点</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#3-%E4%BA%A4%E4%BA%92%E7%89%B9%E7%82%B9"><span class="nav-number">2.3.</span> <span class="nav-text">3 交互特点</span></a></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="yanlw"
      src="/blog/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">yanlw</p>
  <div class="site-description" itemprop="description">穷则独善其身，达则兼济天下！</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/blog/archives/">
          <span class="site-state-item-count">23</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/blog/categories/">
        <span class="site-state-item-count">9</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/blog/tags/">
        <span class="site-state-item-count">18</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://gitee.com/yanlwsometing" title="Gitee → https:&#x2F;&#x2F;gitee.com&#x2F;yanlwsometing" rel="noopener me" target="_blank"><i class="fab fa-gitee fa-fw"></i>Gitee</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:1977712019@qq.com" title="Mail → mailto:1977712019@qq.com" rel="noopener me" target="_blank"><i class="fa fa-envelope fa-fw"></i>Mail</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://weibo.com/" title="Weibo → https:&#x2F;&#x2F;weibo.com&#x2F;" rel="noopener me" target="_blank"><i class="fab fa-weibo fa-fw"></i>Weibo</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://twitter.com/" title="Twitter → https:&#x2F;&#x2F;twitter.com&#x2F;" rel="noopener me" target="_blank"><i class="fab fa-twitter fa-fw"></i>Twitter</a>
      </span>
  </div>

        </div>
      </div>
        <div class="back-to-top animated" role="button" aria-label="返回顶部">
          <i class="fa fa-arrow-up"></i>
          <span>0%</span>
        </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://yanlwsometing.gitee.io/blog/2023/05/18/OCaml%E5%88%9D%E8%AF%86/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.jpg">
      <meta itemprop="name" content="yanlw">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="yanlwsometing">
      <meta itemprop="description" content="穷则独善其身，达则兼济天下！">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="OCaml初识 | yanlwsometing">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          OCaml初识
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2023-05-18 17:51:49" itemprop="dateCreated datePublished" datetime="2023-05-18T17:51:49+08:00">2023-05-18</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">更新于</span>
      <time title="修改时间：2023-12-15 16:56:34" itemprop="dateModified" datetime="2023-12-15T16:56:34+08:00">2023-12-15</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/blog/categories/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/" itemprop="url" rel="index"><span itemprop="name">环境配置</span></a>
        </span>
    </span>

  
    <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv">
      <span class="post-meta-item-icon">
        <i class="far fa-eye"></i>
      </span>
      <span class="post-meta-item-text">阅读次数：</span>
      <span id="busuanzi_value_page_pv"></span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><h3 id="OCaml安装（win10）"><a href="#OCaml安装（win10）" class="headerlink" title="OCaml安装（win10）"></a>OCaml安装（win10）</h3><p>这里我只推荐安装虚拟机Ubuntu，都是血泪史，为了搞这个环境我废了两天:sob:。</p>
<p>如果你不想看我的吐槽小作文，可以直接跳到Ubuntu</p>
<p><strong>注意：建议别搜索教程(我的除外:yum:)，先看官方文档：<a target="_blank" rel="noopener" href="https://www.ocaml.org/docs/up-and-running">Get Up and Running With OCaml · OCaml Tutorials</a></strong></p>
<span id="more"></span>

<h4 id="1-Windows"><a href="#1-Windows" class="headerlink" title="1 Windows"></a>1 Windows</h4><p>当你百度<code>ocaml安装</code>时，你会将那仅有的几篇博客当作你的救星。如果此时你觉得只要跟着作者思路，ocaml安装只是洒洒水而已，恭喜你，又一个大怨种出世了。</p>
<p>我们先不说ocaml对windows版本支持的情况如何，也不说你会不会WSL2以及相应的工具，就单单就是这图像下载器就会明白青春的可贵。</p>
<p><img src="/blog/images/OCaml%E5%88%9D%E8%AF%86/image-20230519154156905.png" alt="image-20230519154156905"></p>
<p>重复的安装，重复的失败。6个小时，但最后我选择了放弃。</p>
<h5 id="1-1-WSL2-VScode"><a href="#1-1-WSL2-VScode" class="headerlink" title="1.1  WSL2+VScode"></a>1.1  WSL2+VScode</h5><p>在官方文档<a target="_blank" rel="noopener" href="https://www.ocaml.org/docs/ocaml-on-windows">OCaml on Windows · OCaml Tutorials</a> 中，明确提到</p>
<blockquote>
<ul>
<li><strong>Only to run, not develop, applications</strong>, use <a target="_blank" rel="noopener" href="https://www.ocaml.org/docs/ocaml-on-windows#docker-images">Docker</a> or <a target="_blank" rel="noopener" href="https://www.ocaml.org/docs/ocaml-on-windows#wsl2">WSL2</a></li>
</ul>
</blockquote>
<p>如果仅仅是运行，可以使用wsl2。wsl2安装：<a target="_blank" rel="noopener" href="https://learn.microsoft.com/zh-cn/windows/wsl/install">安装 WSL | Microsoft Learn</a> </p>
<p>但我觉得最简单的方式还是从Microsoft Store中搜索wsl直接安装，从结果看即是这种<a target="_blank" rel="noopener" href="https://learn.microsoft.com/zh-cn/windows/wsl/install-manual">旧版 WSL 的手动安装步骤 | Microsoft Learn</a>。</p>
<p>（后续：安装wsl2之后，就可以对Ocaml进行安装使用了，其实也挺方便）</p>
<h5 id="1-2-Cygwin"><a href="#1-2-Cygwin" class="headerlink" title="1.2 Cygwin"></a>1.2 Cygwin</h5><p>这是我所在的课题组导师推荐的使用方式，优势方面我还不是很清楚，都是linux，安装相对应的包</p>
<p><a target="_blank" rel="noopener" href="https://cygwin.com/index.html">Cygwin</a></p>
<p><img src="/blog/images/OCaml/image-20230522215152491.png" alt="image-20230522215152491"></p>
</br>

<h4 id="2-CentOS"><a href="#2-CentOS" class="headerlink" title="2 CentOS"></a>2 CentOS</h4><p>如果windows版本的安装过程提醒了我要<strong>挑软柿子捏</strong>，那么CentOS版本则教会了我<strong>一定得先看官方文档</strong>:sob:</p>
<p><strong>注意：CentOS版官方没有提供相关包，这只是吐槽篇，因此可以直接跳过</strong></p>
<ol>
<li>安装虚拟机VMware ：<a target="_blank" rel="noopener" href="https://www.vmware.com/cn/products/workstation-pro/workstation-pro-evaluation.html">下载 VMware Workstation Pro | CN</a> 【记得搜个码白嫖哦】</li>
</ol>
<p><img src="/blog/images/OCaml%E5%88%9D%E8%AF%86/image-20230519155022482.png" alt="image-20230519155022482"></p>
<ol start="2">
<li>下载CentOS镜像：<a target="_blank" rel="noopener" href="https://mirrors.tuna.tsinghua.edu.cn/centos/7/isos/x86_64/">CentOS镜像| 清华大学开源软件镜像站 |</a></li>
<li>创建一个虚拟机并安装：<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1GE411c7T2/?spm_id_from=333.1007.top_right_bar_window_default_collection.content.click&vd_source=e6ae873ea2bd8a84255adeaaeb2a9879">VMware虚拟机之Linux虚拟机安装_哔哩哔哩_bilibili</a></li>
<li>更新yum源</li>
</ol>
<p><img src="/blog/images/OCaml%E5%88%9D%E8%AF%86/image-20230519120146856.png" alt="image-20230519120146856"></p>
<p><img src="/blog/images/OCaml%E5%88%9D%E8%AF%86/image-20230519120306108.png" alt="image-20230519120306108"></p>
<p>当你完成了上面的所有，恭喜你，白费功夫，因为官网说了，没有包！</p>
<p>痛，太痛了。。。</p>
<p><img src="/blog/images/OCaml/image-20230519160059551.png" alt="image-20230519160059551"></p>
<p><img src="/blog/images/OCaml%E5%88%9D%E8%AF%86/image-20230519120351677.png" alt="image-20230519120351677"></p>
<p><img src="/blog/images/OCaml%E5%88%9D%E8%AF%86/image-20230519120427199.png" alt="image-20230519120427199"></p>
</br>

<h4 id="3-Ubuntu"><a href="#3-Ubuntu" class="headerlink" title="3 Ubuntu"></a>3 Ubuntu</h4><p>使用VMware创建虚拟机并安装Ubuntu镜像（中间记得选Ubuntu 64-bit），然后根据上面的文档来做，</p>
<p>Ubuntu镜像：<a target="_blank" rel="noopener" href="https://mirrors.aliyun.com/oldubuntu-releases/releases/22.04/?spm=a2c6h.25603864.0.0.5b5f7ff3qsT7Uv">Ubuntu 22.04</a></p>
<p>镜像命名格式：ubuntu - 版本号 - 镜像类型 - 设备位数 - 文件后缀</p>
<p>终端执行如下指令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">sudo apt-get install opam <span class="comment"># 安装ocaml包管理器</span></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">opam init   <span class="comment"># 初始化</span></span>     </span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash"><span class="built_in">eval</span> $(opam <span class="built_in">env</span>) <span class="comment"># 更新ocaml环境</span></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">opam switch create 4.14.0 <span class="comment">#更换版本</span></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash"><span class="built_in">eval</span> $(opam <span class="built_in">env</span>)</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">ocaml -version <span class="comment">#检查版本号</span></span></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p><strong>注意</strong>：</p>
<p>或者跟着一位前辈一步一步来<a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1sY4y1t7gd/?spm_id_from=333.1007.top_right_bar_window_default_collection.content.click">01-Ocaml环境搭建_哔哩哔哩_bilibili</a></p>
<ol>
<li>中间前辈插入了启动脚本，命令应该为<code>vim ~/.bashrc</code></li>
<li>版本更换命令如上</li>
</ol>
</br>

<h3 id="OCaml初始"><a href="#OCaml初始" class="headerlink" title="OCaml初始"></a>OCaml初始</h3><h4 id="1-编程范式对比"><a href="#1-编程范式对比" class="headerlink" title="1 编程范式对比"></a>1 编程范式对比</h4><table>
<thead>
<tr>
<th></th>
<th>过程式</th>
<th>函数式</th>
<th>面向对象</th>
</tr>
</thead>
<tbody><tr>
<td>直观表现</td>
<td>语句的连续执行</td>
<td>各种函数的组合，定义函数，调用函数</td>
<td>对象之间交互</td>
</tr>
<tr>
<td>关键词</td>
<td>状态改变</td>
<td>纯函数概念</td>
<td>封装、继承、多态</td>
</tr>
<tr>
<td>重复方式</td>
<td>循环</td>
<td>递归</td>
<td>循环</td>
</tr>
</tbody></table>
<p>纯函数：只做输入输出的改变，不做副改变</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">int</span> <span class="title function_">f</span> <span class="params">(<span class="type">int</span> a)</span> &#123;<span class="keyword">return</span> a+<span class="number">1</span>;&#125; # 纯函数</span><br><span class="line"><span class="type">int</span> <span class="title function_">g</span> <span class="params">(<span class="type">int</span> a)</span> &#123;<span class="type">int</span> b=a; <span class="keyword">return</span> a;&#125;   </span><br></pre></td></tr></table></figure>

<h4 id="2-特点"><a href="#2-特点" class="headerlink" title="2 特点"></a>2 特点</h4><blockquote>
<ol>
<li><p>多范式语言。</p>
</li>
<li><p>自动管理内存。</p>
</li>
<li><p>静态类型。 在执行之前检测表达式类型，不正确不执行</p>
</li>
<li><p>多态参数。</p>
</li>
<li><p>可以自己定义联合类型。user type</p>
</li>
<li><p>模块化。</p>
</li>
</ol>
</blockquote>
<h4 id="3-交互特点"><a href="#3-交互特点" class="headerlink" title="3 交互特点"></a>3 交互特点</h4><blockquote>
<p>命令行对话式交互</p>
<p>编译器执行时内部主要的过程有：</p>
<ol>
<li>读取每一句代码且检查是否有格式错误</li>
<li>检查是否有类型错误</li>
<li>执行语句</li>
<li>显示结果</li>
</ol>
</blockquote>

    </div>

    
    
    

    <footer class="post-footer">
          <div class="post-tags">
              <a href="/blog/tags/wsl2/" rel="tag"># wsl2</a>
              <a href="/blog/tags/%E5%87%BD%E6%95%B0%E5%BC%8F%E7%BC%96%E7%A8%8B/" rel="tag"># 函数式编程</a>
              <a href="/blog/tags/VMware/" rel="tag"># VMware</a>
              <a href="/blog/tags/ocaml%E5%AE%89%E8%A3%85/" rel="tag"># ocaml安装</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/blog/2023/05/14/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/" rel="prev" title="数据结构">
                  <i class="fa fa-chevron-left"></i> 数据结构
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/blog/2023/05/27/%E5%BF%AB%E6%8D%B7%E9%94%AE%E4%BD%BF%E7%94%A8/" rel="next" title="快捷键使用">
                  快捷键使用 <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">yanlw</span>
</div>
<div class="busuanzi-count">
    <span class="post-meta-item" id="busuanzi_container_site_uv">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-item" id="busuanzi_container_site_pv">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/pisces/" rel="noopener" target="_blank">NexT.Pisces</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <div class="reading-progress-bar"></div>

  <a href="https://gitee.com/yanlwsometing" class="github-corner" title="在 GitHub 上关注我" aria-label="在 GitHub 上关注我" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.4/jquery.min.js" integrity="sha256-oP6HI9z1XaZNBrJURtCoUT5SUnxFr8s3BzRl+cbzUq8=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js" integrity="sha256-yt2kYMy0w8AbtF89WXb2P1rfjcP/HTHLT7097U8Y5b8=" crossorigin="anonymous"></script>
<script src="/blog/js/comments.js"></script><script src="/blog/js/utils.js"></script><script src="/blog/js/next-boot.js"></script>

  


  <script src="/blog/js/third-party/fancybox.js"></script>



  
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>





</body>
</html>
